#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;

int n, m;
int g[N];
int v[N], b[N];
int f[N], d[N];
void init(int n) { rep(i, 0, n) f[i] = i, d[i] = 0; }
int find(int x) {
  if (f[x] == x) return x;
  int y = find(f[x]);
  d[x] += d[f[x]];
  return f[x] = y;
}
bool merge(int x, int y, int z) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return false;
  f[fy] = fx, d[fy] = d[x] + z - d[y];
  return true;
}
int work(int a, int b) {
  int res = 0;
  int x = a;
  while (b > 0 && x) {
    int y = find(x);
    if (y == x) {  // available
      res++, b--;
      if (!merge(g[x], x, 1)) merge(0, x, 1e8);  // loop is done
      x = g[x];
    } else {
      b -= d[x];
      x = y;
    }
  }
  return res;
}
void solve() {
  cin >> n >> m;
  rep(i, 1, n) cin >> g[i];
  rep(i, 1, m) cin >> v[i];
  rep(i, 1, m) cin >> b[i];
  init(n + 1);
  int res = 0;
  rep(i, 1, m) {
    int a = (res + v[i] - 1) % n + 1;
    res = work(a, b[i]);
    cout << res << endl;
  }
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}